package com.ht.temp.controller;


import com.ht.temp.entity.Equipment;
import com.ht.temp.service.IEquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mayke_zhou
 * @since 2018-12-19
 */
@RestController
@RequestMapping("/equipmentController")
public class EquipmentController {
    @Autowired
    private IEquipmentService equipmentService;

    @RequestMapping(value = "/getByEquipment",method = RequestMethod.GET)
    public List<Equipment> selectByEquipment(Equipment equipment){
        return equipmentService.selectByEquipment(equipment);
    }


    @RequestMapping(value = "/editState",method = RequestMethod.POST)
    public Integer editState(Integer equipmentId,Integer state){
        return equipmentService.editState(state,equipmentId);
    }

    @RequestMapping(value = "/addEquipment",method = RequestMethod.POST)
    public Integer insertByEquipment(Equipment equipment){
        System.out.println(equipment.getEquipmentWorkshop());
        return equipmentService.insertSelective(equipment);
    }

    @RequestMapping(value = "/removeEquipment",method = RequestMethod.POST)
    public Integer deleteByEquipment(Equipment equipment){
        return equipmentService.deleteByPrimaryKey(equipment.getEquipmentId());
    }

    @RequestMapping(value = "/updateEquipment",method = RequestMethod.POST)
    public Integer updateByEquipment(Equipment equipment){
        return equipmentService.editByEquipment(equipment);
    }

}
